<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<!-- <script>
			let nav=(function(){
				let num=10;
				
				function show(){
					console.log("111")
				}
				
				return {
					num,
					show
				}
			})()
			
			console.log(nav.num);
		</script> -->
		
		
		<script>
			(function(){
				let num=10;
				
				function show(){
					console.log("111")
				}

				let obj={
					num,
					show
				}
				
				if(window!==undefined){//js都有window,js用浏览器
					window.obj=obj;
				}
				
				//nodejs 中 module.exports(了解)
				if(typeof module==="object"&& typeof module.exports==="object"){
					//nodejs(js可以直接在nodejs里面写)，没有window  module.exports
					//webpack   module.exports
					module.exports=obj;
				}
				
			})()
			
			console.log(window.obj.num);
		</script>
	</body>
</html>
